home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Aug 15 1996
- // Author: llm
- //
- // Description:
- // This script initializes the Shelf. Initialization involves
- // determining the initial Shelf preferences, creating the UI and
- // setting the initial visibility.
- //
- {
- // Check Shelf tab preferences.
- //
- int $i, $nShelves;
- int $usePrefs = false;
- int $isFirstTime = false;
- string $name, $proc;
- string $shelfDir, $sysReturn, $tmp;
- string $unsortedFiles[];
- string $files[];
- string $names[];
-
- //
- // get a list of files in the shelves directory
- //
- $shelfDir = `internalVar -userShelfDir`;
- $unsortedFiles = `getFileList -folder $shelfDir -fs "shelf_*.mel"`;
- //
- // sort this list
- //
- $files = sort ($unsortedFiles);
- $nShelves = size($files);
-
- if (0 == $nShelves) {
-
- $isFirstTime = true;
-
- //
- // No existing shelves, so use the default shelf setup.
- //
- if (`about -windows` || `about -mac`) {
- //
- // Create a new set of default shelves for Windows
- // only.
- //
-
- // The following table defines the order of shelves
- // available for each version of Maya.
- //
- // All Versions Complete Unlimited
- // --------------------------------------------
- // General General General
- // Curves Curves Curves
- // Surfaces Surfaces Surfaces
- // Polygons Polygons Polygons
- // Subdivs Subdivs
- // Deformation Deformation Deformation
- // Animation Animation Animation
- // Dynamics Dynamics
- // Rendering Rendering Rendering
- // PaintEffects PaintEffects
- // Cloth
- // Fluids
- // Fur
- //
- // From the table above you will count that there
- // are:
- //
- // 7 Shelves for all versions
- // 10 Complete shelves
- // 13 Unlimited shelves
-
- // The General, Curves, Surfaces, and Polygons shelves
- // are all available for all versions of Maya.
- //
- // Note that each shelf may have individual items available
- // only in certain versions. See each shelf script for these
- // items.
- //
- optionVar
- -stringValue shelfName1 "General"
- -stringValue shelfFile1 "shelf_General"
- -intValue shelfLoad1 true
-
- -stringValue shelfName2 "Curves"
- -stringValue shelfFile2 "shelf_Curves"
- -intValue shelfLoad2 true
-
- -stringValue shelfName3 "Surfaces"
- -stringValue shelfFile3 "shelf_Surfaces"
- -intValue shelfLoad3 true
-
- -stringValue shelfName4 "Polygons"
- -stringValue shelfFile4 "shelf_Polygons"
- -intValue shelfLoad4 true
- ;
-
- if (`licenseCheck -type complete`) {
- //
- // --- Complete ---
- //
- // Create the Subdivs, Deformation, Animation, Dynamics,
- // and Rendering shelves.
- //
- optionVar
- -stringValue shelfName5 "Subdivs"
- -stringValue shelfFile5 "shelf_Subdivs"
- -intValue shelfLoad5 true
-
- -stringValue shelfName6 "Deformation"
- -stringValue shelfFile6 "shelf_Deformation"
- -intValue shelfLoad6 true
-
- -stringValue shelfName7 "Animation"
- -stringValue shelfFile7 "shelf_Animation"
- -intValue shelfLoad7 true
-
- -stringValue shelfName8 "Dynamics"
- -stringValue shelfFile8 "shelf_Dynamics"
- -intValue shelfLoad8 true
-
- -stringValue shelfName9 "Rendering"
- -stringValue shelfFile9 "shelf_Rendering"
- -intValue shelfLoad9 true
-
- -stringValue shelfName10 "PaintEffects"
- -stringValue shelfFile10 "shelf_PaintEffects"
- -intValue shelfLoad10 true
- ;
-
- if( fluidEditLicenseFound() ) {
- //
- // --- Unlimited ---
- //
- // Add the Cloth, Fur and Fluids shelves.
- //
- optionVar
- -stringValue shelfName11 "Cloth"
- -stringValue shelfFile11 "shelf_Cloth"
- -intValue shelfLoad11 true
-
- -stringValue shelfName12 "Fluids"
- -stringValue shelfFile12 "shelf_Fluids"
- -intValue shelfLoad12 true
-
- -stringValue shelfName13 "Fur"
- -stringValue shelfFile13 "shelf_Fur"
- -intValue shelfLoad13 true
-
- // Add empty shelf.
- //
- -stringValue shelfName14 "Custom"
- -stringValue shelfFile14 "shelf_Shelf1"
- -intValue shelfLoad14 true
- ;
-
- $nShelves = 14;
-
- } else {
- //
- // --- Complete ---
- //
- // Add empty shelf.
- //
- optionVar
- -stringValue shelfName11 "Custom"
- -stringValue shelfFile11 "shelf_Shelf1"
- -intValue shelfLoad11 true
- ;
-
- $nShelves = 11;
- }
-
- } else {
- //
- // --- All Versions ---
- //
- // Create the Deformation, Animation, and Rendering
- // shelves.
- //
- optionVar
- -stringValue shelfName5 "Deformation"
- -stringValue shelfFile5 "shelf_Deformation"
- -intValue shelfLoad5 true
-
- -stringValue shelfName6 "Animation"
- -stringValue shelfFile6 "shelf_Animation"
- -intValue shelfLoad6 true
-
- -stringValue shelfName7 "Rendering"
- -stringValue shelfFile7 "shelf_Rendering"
- -intValue shelfLoad7 true
-
- -stringValue shelfName8 "Custom"
- -stringValue shelfFile8 "shelf_Shelf1"
- -intValue shelfLoad8 true
- ;
-
- $nShelves = 8;
- }
-
- optionVar
- -stringValue shelfItemSize "Small"
- -stringValue shelfItemStyle "iconOnly"
-
- -intValue isShelfVisible true
- -intValue isShelfLoad true
- -intValue numShelves $nShelves;
-
- } else {
- //
- // For Irix and Linux, stick with the old default
- // shelves.
- //
- $nShelves = 2;
- optionVar
- -stringValue shelfName1 "Shelf1"
- -stringValue shelfFile1 "shelf_Common"
- -intValue shelfLoad1 true
-
- -stringValue shelfName2 "Shelf2"
- -stringValue shelfFile2 "shelf_Shelf2"
- -intValue shelfLoad2 true
-
- -stringValue shelfItemSize "Small"
- -stringValue shelfItemStyle "iconOnly"
-
- -intValue isShelfVisible true
- -intValue isShelfLoad true
- -intValue numShelves $nShelves;
- }
-
- } else {
- //
- // Compare existing prefs with what's in the directory.
- // It is preferable to use prefs as they contain order info also.
- //
- int $nArr = `optionVar -q numShelves`;
- string $prefFiles[];
- string $sortedPrefFiles[];
-
- // build array of files from prefs and sort it
- //
- for ($i = 0; $i < $nShelves; $i++) {
- $prefFiles[$i] = (`optionVar -q ("shelfFile"+($i+1))` + ".mel");
- }
- $sortedPrefFiles = sort ($prefFiles);
-
- // compare with the file in the directory.
- // - if there is any discrpency then don't trust the prefs.
- //
- if (size($sortedPrefFiles) == $nShelves) {
- $usePrefs = true;
- for ($i = 0; $i < $nShelves; $i++) {
- if ($sortedPrefFiles[$i] != $files[$i]) {
- $usePrefs = false;
- break;
- }
- }
- }
-
- if (!$usePrefs) {
- //
- // Create shelves from directory
- // The double backslash is to prevent the '.' from being
- // used as a wildcard.
- //
- for ($i = 1; $i <= $nShelves; $i++) {
- $tmp = $files[$i-1];
- $proc = `substitute "\\.mel" $tmp ""`;
- $name = `substitute "shelf_" $proc ""`;
-
- optionVar
- -stringValue ("shelfName"+$i) $name
- -stringValue ("shelfFile"+$i) $proc
- -intValue ("shelfLoad"+$i) true;
- }
-
- optionVar -intValue numShelves $nShelves;
- }
- }
-
- // Create the Shelf.
- //
- if (`exists shelf`) {
- eval "source shelf";
- }
-
- // Attach a callback so we know when the Shelf is made visible or
- // invisible.
- //
- setUIComponentStateCallback("Shelf", "shelfVisibilityStateChange");
-
- // Set the Shelf's initial visibility.
- //
- setShelfVisible(`optionVar -q isShelfVisible`);
-
- // If this is the first time shelves are loaded then we must rename
- // the option var for the Custom shelf (Windows) and the Common
- // shelf (other platforms) to match the corresponding shelf labels.
- //
- // If the file and label don't match then the shelves won't load
- // from preferences and retain the user's order (they'll
- // come back in alphabetical order).
- //
- if ($isFirstTime) {
- if (`about -windows` || `about -mac`) {
- optionVar -stringValue ("shelfFile" + $nShelves) "shelf_Custom";
- } else {
- optionVar -stringValue shelfFile1 "shelf_Shelf1";
- }
- }
-
- // Fix shelf items that have obsolete or incorrect commands
- // associated with them. Once the shelves have been fixed,
- // turn on a variable so that they are not processed again
- // in this version.
- string $nowVer = `about -v`;
- string $lastVer = "";
- if( `optionVar -exists shelvesLastUpdated` ) {
- $lastVer = `optionVar -q shelvesLastUpdated`;
- }
-
- if( $nowVer != $lastVer ) {
- optionVar -sv shelvesLastUpdated $nowVer;
- source updateShelves.mel;
- }
- }
-
- global proc int shelfVisibilityStateChange(
- int $newState,
- string $layout)
- //
- // Description:
- // This procedure is called whenever the visibility state of the
- // Shelf is changed.
- //
- // Create the contents of the Shelf when it is shown for the first
- // time.
- //
- // Arguments:
- // newState - The new visibile state of the Shelf.
- //
- // layout - The parent layout for the Shelf.
- //
- // Returns:
- // true - If the change of state is to be allowed.
- //
- // false - If the state change is rejected.
- //
- {
- global int $gShelfCreated = false;
-
- int $result = true;
-
- if ($newState) {
-
- // Load the contents of the Shelf right before it becomes visible
- // for the very first time.
- //
- if (!$gShelfCreated) {
- buildShelves();
- $gShelfCreated = true;
- }
-
- } else {
- }
-
- // Defer these commands because this proc is called when the visibility
- // state is about to change. This proc must return true to accept
- // the state change. After this proc returns then restore the
- // panel focus and update the pref menu.
- //
- evalDeferred("restoreLastPanelWithFocus(); updatePrefsMenu();");
-
- return $result;
- }
-